package com.person.leetcode.editor.cn;

/**
  * 55.跳跃游戏
  * 2022-08-10 15:25:43
**/
public class Sequence_0055_JumpGame {
    public static void main(String[] args) {
        Solution solution = new Sequence_0055_JumpGame().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
    public class Solution {
        public boolean canJump(int[] nums) {
            int n = nums.length;
            int rightmost = 0;
            for (int i = 0; i < n; ++i) {
                if (i <= rightmost) {//可达性
                    rightmost = Math.max(rightmost, i + nums[i]);
                    if (rightmost >= n - 1) {
                        return true;
                    }
                }
            }
            return false;
        }
    }


//leetcode submit region end(Prohibit modification and deletion)
}